package com.guojiaming.shop.controller;

import com.guojiaming.shop.service.BookService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * @author vivo
 */
@Controller
@RequestMapping("book")
public class BookHtmlController {
    @Resource
    private BookService bookService;

    @GetMapping()
    public String index() {
        return "index";
    }

    @GetMapping("/{bookType}")
    public String read(ModelMap modelMap, @PathVariable Integer bookType, Integer id, Integer type) {
        modelMap.addAttribute("book", bookService.read(bookType, id, type));
        return "book";
    }
}
